package cn.com.nes.site.controller.inventory;

import cn.com.nes.common.web.CommonResult;
import cn.com.nes.site.entity.vo.inventory.DelApplyInVO;
import cn.com.nes.site.entity.vo.inventory.SaveApplyInfoInVO;
import cn.com.nes.site.entity.vo.inventory.UpdateApplyGoodsInfoInVO;
import cn.com.nes.site.service.inventory.GOrderInApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Api(tags = {"项目模块 - 库存管理接口"})
@Controller
@RequestMapping("/v2/inventory/orderin")
public class GOrderInController {

    @Resource
    private GOrderInApplyService gOrderInApplyService;

    @ApiOperation("入库管理-保存入库申请单信息")
    @RequestMapping(value = "saveApplyInfo", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> saveApplyInfo(@RequestBody @Validated SaveApplyInfoInVO vo) throws Exception {
        Integer res = gOrderInApplyService.saveApplyInfo(vo);
        return CommonResult.ok();
    }

    @ApiOperation("入库管理-修改申请单货品信息")
    @RequestMapping(value = "updateApplyGoodsInfo", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> updateApplyGoodsInfo(@RequestBody @Validated UpdateApplyGoodsInfoInVO vo) throws Exception {
        Integer res = gOrderInApplyService.updateApplyGoodsInfo(vo);
        return CommonResult.ok();
    }

    @ApiOperation("入库管理-删除入库申请单")
    @RequestMapping(value = "delApply", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<?> delApply(@RequestBody @Validated DelApplyInVO vo) throws Exception {
        Integer res = gOrderInApplyService.delApply(vo);
        return CommonResult.ok();
    }

}
